package com.yt.sys.api.client;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yt.common.constant.Result;
import com.yt.common.enums.CodeEnum;
import com.yt.common.utils.StrUtils;
import com.yt.sys.models.bo.EmployeeAccountCreateBO;
import com.yt.sys.models.bo.EmployeePasswordUpdateBO;
import com.yt.sys.models.vo.EmployeeLoginInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yt.sys.models.service.ILoginInfoService;
import com.yt.sys.models.service.IEmployeeRoleService;
import com.yt.sys.models.service.IPermissionService;
import com.yt.sys.models.bo.LoginInfoBO;
import com.yt.sys.models.dto.LoginInfoDTO;
import com.yt.sys.models.dto.PermissionDTO;
import com.yt.sys.models.bo.LoginInfoSaveBO;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

// 添加相关的BO和DTO类导入
import com.yt.user.models.bo.CustomerInfoSaveBO;
import com.yt.user.models.bo.PhoneInfoSaveBO;
import com.yt.user.models.bo.AccountInfoSaveBO;
import com.yt.user.models.dto.CustomerInfoDTO;
import com.yt.user.models.dto.PhoneInfoDTO;
import com.yt.user.models.dto.AccountInfoDTO;
import com.yt.user.models.dto.CustomerPhoneDTO;

// 添加Dubbo服务引用
import org.apache.dubbo.config.annotation.DubboReference;
import com.yt.user.models.service.ICustomerInfoService;
import com.yt.user.models.service.IPhoneInfoService;
import com.yt.user.models.service.IAccountInfoService;
import com.yt.user.models.service.ICustomerPhoneService;

/**
 * 登录信息控制器
 *
 * @author yzz
 * @Date 2025-10-22 09:46:30
 */

@RestController
@RequestMapping("/api/loginInfo")
@Slf4j
@Api(value = "LoginInfoApiController",tags = "登录信息Api接口")
public class LoginInfoApiController {

    @DubboReference
    private ILoginInfoService loginInfoService;
    
    @DubboReference
    private IEmployeeRoleService employeeRoleService;
    
    @DubboReference
    private IPermissionService permissionService;
    
    // 添加用户相关服务的引用
    @DubboReference
    private ICustomerInfoService customerInfoService;
    
    @DubboReference
    private IPhoneInfoService phoneInfoService;
    
    @DubboReference
    private IAccountInfoService accountInfoService;
    
    @DubboReference
    private ICustomerPhoneService customerPhoneService;
    
    @Autowired
    private ObjectMapper objectMapper;

    @PostMapping("/get")
    @ApiOperation(value = "根据id查找",notes = "根据id查找")
    @ApiImplicitParam(name = "id",value = "id",required = true,paramType = "query", dataType = "Long")
    // 移除了@PreAuthorize注解以开放此接口的访问权限
    public Result<LoginInfoDTO> get(@RequestParam(value = "id", required = false) Long id){
        if(id == null){
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "缺少必需的参数: id");
        }

        LoginInfoDTO dto = loginInfoService.selectById(id);

        return new Result<>(dto);
    }
    
    @PostMapping("/changePassword")
    @ApiOperation(value = "修改账户密码", notes = "根据账号和旧密码修改账户密码")
    public Result changePassword(
            @RequestParam(value = "account", required = false) String accountParam,
            @RequestParam(value = "oldPassword", required = false) String oldPasswordParam,
            @RequestParam(value = "newPassword", required = false) String newPasswordParam,
            @RequestBody(required = false) String requestBodyString) {
        // 处理可能的参数传递方式（表单或JSON）
        String account = accountParam;
        String oldPassword = oldPasswordParam;
        String newPassword = newPasswordParam;
        
        // 如果通过RequestParam没有获取到值，尝试从RequestBody获取
        if ((StrUtils.isEmpty(account) || StrUtils.isEmpty(oldPassword) || StrUtils.isEmpty(newPassword)) 
                && StrUtils.isNotEmpty(requestBodyString)) {
            try {
                JsonNode jsonNode = objectMapper.readTree(requestBodyString);
                if (jsonNode.has("account")) {
                    account = jsonNode.get("account").asText();
                }
                if (jsonNode.has("oldPassword")) {
                    oldPassword = jsonNode.get("oldPassword").asText();
                }
                if (jsonNode.has("newPassword")) {
                    newPassword = jsonNode.get("newPassword").asText();
                }
            } catch (Exception e) {
                log.error("解析请求体失败", e);
            }
        }
        
        // 参数校验
        if (StrUtils.isEmpty(account) || StrUtils.isEmpty(oldPassword) || StrUtils.isEmpty(newPassword)) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "账号、旧密码或新密码不能为空");
        }
        
        if (newPassword.length() < 6) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "密码长度不能少于6位");
        }
        
        // 查询用户信息
        Wrapper<LoginInfoDTO> wrapper = new EntityWrapper<>();
        wrapper.eq("account", account);
        LoginInfoDTO loginInfo = loginInfoService.selectOne(wrapper);
        
        // 检查用户是否存在
        if (loginInfo == null) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "账号不存在");
        }
        
        // 验证旧密码
        if (!verifyPassword(oldPassword, loginInfo.getPassword())) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "旧密码错误");
        }
        
        // 更新密码
        loginInfo.setPassword(newPassword); // 实际项目中应该加密存储
        boolean result = loginInfoService.updateById(loginInfo);
        
        if (result) {
            return new Result();
        } else {
            return new Result<>(CodeEnum.FAIL_100008.getCode(), "密码更新失败");
        }
    }
    
    @PostMapping("/employee/create")
    @ApiOperation(value = "为员工创建登录账户", notes = "为员工创建登录账户")
    // 移除了@PreAuthorize注解以开放此接口的访问权限
    public Result createEmployeeAccount(@RequestBody EmployeeAccountCreateBO createBO) {
        // 参数校验
        if (StrUtils.isEmpty(createBO.getEmployeeId()) || 
            StrUtils.isEmpty(createBO.getUsername()) || 
            StrUtils.isEmpty(createBO.getPassword())) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        
        // 检查是否已存在该员工的账户
        Wrapper<LoginInfoDTO> checkWrapper = new EntityWrapper<>();
        checkWrapper.eq("employee_id", createBO.getEmployeeId());
        int count = loginInfoService.selectCount(checkWrapper);
        if (count > 0) {
            return new Result<>(CodeEnum.FAIL_100007.getCode(), "该员工已存在登录账户");
        }
        
        // 检查用户名是否已存在
        Wrapper<LoginInfoDTO> usernameCheckWrapper = new EntityWrapper<>();
        usernameCheckWrapper.eq("account", createBO.getUsername());
        int usernameCount = loginInfoService.selectCount(usernameCheckWrapper);
        if (usernameCount > 0) {
            return new Result<>(CodeEnum.FAIL_100007.getCode(), "用户名已存在");
        }
        
        // 创建登录账户
        LoginInfoSaveBO saveBO = new LoginInfoSaveBO();
        saveBO.setAccount(createBO.getUsername());
        saveBO.setPassword(createBO.getPassword()); // 实际项目中应该加密存储
        saveBO.setEmployeeId(createBO.getEmployeeId());
        
        boolean result = loginInfoService.add(saveBO);
        if (result) {
            return new Result();
        } else {
            return new Result<>(CodeEnum.FAIL_100007);
        }
    }
    
    @PostMapping("/employee/updatePassword")
    @ApiOperation(value = "更新员工登录密码", notes = "更新员工登录密码")
    // 移除了@PreAuthorize注解以开放此接口的访问权限
    public Result updateEmployeePassword(@RequestBody EmployeePasswordUpdateBO updateBO) {
        // 参数校验
        if (StrUtils.isEmpty(updateBO.getEmployeeId()) || 
            StrUtils.isEmpty(updateBO.getUsername()) || 
            StrUtils.isEmpty(updateBO.getNewPassword())) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        
        // 查找对应的登录信息
        Wrapper<LoginInfoDTO> wrapper = new EntityWrapper<>();
        wrapper.eq("employee_id", updateBO.getEmployeeId());
        wrapper.eq("account", updateBO.getUsername());
        LoginInfoDTO loginInfo = loginInfoService.selectOne(wrapper);
        
        // 检查是否存在该账户
        if (loginInfo == null) {
            return new Result<>(CodeEnum.FAIL_100007.getCode(), "未找到匹配的账户信息");
        }
        
        // 更新密码
        loginInfo.setPassword(updateBO.getNewPassword()); // 实际项目中应该加密存储
        boolean result = loginInfoService.updateById(loginInfo);
        
        if (result) {
            return new Result();
        } else {
            return new Result<>(CodeEnum.FAIL_100008);
        }
    }
    
    @PostMapping("/employee/{employeeId}")
    @ApiOperation(value = "获取指定员工的登录账户信息", notes = "获取指定员工的登录账户信息")
    // 移除了@PreAuthorize注解以开放此接口的访问权限
    public Result<EmployeeLoginInfoVO> getEmployeeLoginInfo(@PathVariable("employeeId") String employeeId) {
        // 参数校验
        if (employeeId == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        
        // 查询员工关联的登录信息
        Wrapper<LoginInfoDTO> wrapper = new EntityWrapper<>();
        wrapper.eq("employee_id", employeeId);
        LoginInfoDTO loginInfo = loginInfoService.selectOne(wrapper);
        
        // 如果没有找到登录信息，返回空结果
        if (loginInfo == null) {
            return new Result<>();
        }
        
        // 转换为VO对象（不包含密码字段）
        EmployeeLoginInfoVO employeeLoginInfoVO = new EmployeeLoginInfoVO();
        employeeLoginInfoVO.setAccount(loginInfo.getAccount());
        employeeLoginInfoVO.setEmployeeId(loginInfo.getEmployeeId());
        
        return new Result<>(employeeLoginInfoVO);
    }

    @ApiOperation(value = "登录信息列表",notes = "登录信息列表")
    @PostMapping("/queryPageList")
    // 移除了@PreAuthorize注解以开放此接口的访问权限
    public Result<Page<LoginInfoDTO>> queryPageList(LoginInfoBO bo){
        Wrapper<LoginInfoDTO> wrapper = new EntityWrapper<>();
        if (bo.getStartDate() != null){
            wrapper.ge("create_time", bo.getStartDate());
        }
        if (bo.getEndDate() != null){
            wrapper.le("create_time", bo.getEndDate());

        }
        Page<LoginInfoDTO> page = new Page<>(bo.getPageNo(), bo.getPageSize());
        page = loginInfoService.selectPage(page, wrapper);

        return new Result<>(page);
    }
    
    @PostMapping("/login")
    @ApiOperation(value = "员工登录接口", notes = "员工登录并返回权限信息")
    public Result<Map<String, Object>> login(
            @RequestParam(value = "account", required = false) String accountParam,
            @RequestParam(value = "password", required = false) String passwordParam,
            @RequestParam(value = "username", required = false) String usernameParam,
            @RequestBody(required = false) String requestBodyString) {
        // 处理可能的参数传递方式（表单或JSON）
        String account = accountParam;
        String password = passwordParam;
        
        // 如果通过RequestParam没有获取到account值，尝试使用username参数
        if (StrUtils.isEmpty(account)) {
            account = usernameParam;
        }
        
        // 如果通过RequestParam没有获取到值，尝试从RequestBody获取
        if ((StrUtils.isEmpty(account) || StrUtils.isEmpty(password)) && StrUtils.isNotEmpty(requestBodyString)) {
            try {
                JsonNode jsonNode = objectMapper.readTree(requestBodyString);
                // 尝试多种可能的账号字段名
                if (jsonNode.has("account")) {
                    account = jsonNode.get("account").asText();
                } else if (jsonNode.has("username")) {
                    account = jsonNode.get("username").asText();
                } else if (jsonNode.has("loginName")) {
                    account = jsonNode.get("loginName").asText();
                }
                
                // 尝试多种可能的密码字段名
                if (jsonNode.has("password")) {
                    password = jsonNode.get("password").asText();
                } else if (jsonNode.has("pwd")) {
                    password = jsonNode.get("pwd").asText();
                }
            } catch (Exception e) {
                // JSON解析失败，忽略错误，继续使用表单参数
                System.err.println("Failed to parse request body as JSON: " + e.getMessage());
            }
        }
        
        // 参数校验
        if (StrUtils.isEmpty(account) || StrUtils.isEmpty(password)) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "账号或密码不能为空");
        }
        
        // 查询用户信息
        Wrapper<LoginInfoDTO> wrapper = new EntityWrapper<>();
        wrapper.eq("account", account);
        LoginInfoDTO loginInfo = loginInfoService.selectOne(wrapper);
        
        // 检查用户是否存在
        if (loginInfo == null) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "账号或密码错误");
        }
        
        // 验证密码 (实际项目中应该使用加密验证)
        // 修复：使用安全的密码验证方式
        if (!verifyPassword(password, loginInfo.getPassword())) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "账号或密码错误");
        }
        
        // 获取员工ID
        String employeeId = loginInfo.getEmployeeId();
        if (StrUtils.isEmpty(employeeId)) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "该账户未绑定员工信息");
        }
        
        // 获取员工权限列表
        List<PermissionDTO> permissions = permissionService.getUserPermissions(employeeId);
        
        // 构造返回结果
        Map<String, Object> result = new HashMap<>();
        result.put("account", account);
        result.put("employeeId", employeeId);
        result.put("permissions", permissions);
        
        return new Result<>(result);
    }
    
    @PostMapping("/customer/login")
    @ApiOperation(value = "客户登录接口", notes = "客户登录并返回客户信息")
    public Result<Map<String, Object>> customerLogin(
            @RequestParam(value = "account", required = false) String accountParam,
            @RequestParam(value = "password", required = false) String passwordParam,
            @RequestParam(value = "username", required = false) String usernameParam,
            @RequestBody(required = false) String requestBodyString) {
        // 处理可能的参数传递方式（表单或JSON）
        String account = accountParam;
        String password = passwordParam;
        
        // 如果通过RequestParam没有获取到account值，尝试使用username参数
        if (StrUtils.isEmpty(account)) {
            account = usernameParam;
        }
        
        // 如果通过RequestParam没有获取到值，尝试从RequestBody获取
        if ((StrUtils.isEmpty(account) || StrUtils.isEmpty(password)) && StrUtils.isNotEmpty(requestBodyString)) {
            try {
                JsonNode jsonNode = objectMapper.readTree(requestBodyString);
                // 尝试多种可能的账号字段名
                if (jsonNode.has("account")) {
                    account = jsonNode.get("account").asText();
                } else if (jsonNode.has("username")) {
                    account = jsonNode.get("username").asText();
                } else if (jsonNode.has("loginName")) {
                    account = jsonNode.get("loginName").asText();
                }
                
                // 尝试多种可能的密码字段名
                if (jsonNode.has("password")) {
                    password = jsonNode.get("password").asText();
                } else if (jsonNode.has("pwd")) {
                    password = jsonNode.get("pwd").asText();
                }
            } catch (Exception e) {
                // JSON解析失败，忽略错误，继续使用表单参数
                System.err.println("Failed to parse request body as JSON: " + e.getMessage());
            }
        }
        
        // 参数校验
        if (StrUtils.isEmpty(account) || StrUtils.isEmpty(password)) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "账号或密码不能为空");
        }
        
        // 查询用户信息
        Wrapper<LoginInfoDTO> wrapper = new EntityWrapper<>();
        wrapper.eq("account", account);
        LoginInfoDTO loginInfo = loginInfoService.selectOne(wrapper);
        
        // 检查用户是否存在
        if (loginInfo == null) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "账号或密码错误");
        }
        
        // 验证密码 (实际项目中应该使用加密验证)
        // 修复：使用安全的密码验证方式
        if (!verifyPassword(password, loginInfo.getPassword())) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "账号或密码错误");
        }
        
        // 获取客户ID
        String customerId = loginInfo.getCusId();
        if (StrUtils.isEmpty(customerId)) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "该账户未绑定客户信息");
        }
        
        // 构造返回结果
        Map<String, Object> result = new HashMap<>();
        result.put("account", account);
        result.put("customerId", customerId);
        
        return new Result<>(result);
    }
    
    /**
     * 客户注册接口
     * @param customerRegisterBO 客户注册信息
     * @return 注册结果
     */
    @PostMapping("/customer/register")
    @ApiOperation(value = "客户注册接口", notes = "客户注册涉及登录表、客户信息表、手机号表、账户表")
    public Result customerRegister(@RequestBody CustomerRegisterBO customerRegisterBO) {
        // 参数校验
        if (customerRegisterBO == null) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "注册信息不能为空");
        }
        
        // 如果未提供账号，则默认使用手机号作为账号
        if (StrUtils.isEmpty(customerRegisterBO.getAccount())) {
            customerRegisterBO.setAccount(customerRegisterBO.getPhone());
        }
        
        if (StrUtils.isEmpty(customerRegisterBO.getPassword())) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "登录密码不能为空");
        }
        
        if (StrUtils.isEmpty(customerRegisterBO.getPhone())) {
            return new Result<>(CodeEnum.FAIL_100002.getCode(), "手机号不能为空");
        }
        
        // 检查账号是否已存在
        Wrapper<LoginInfoDTO> loginWrapper = new EntityWrapper<>();
        loginWrapper.eq("account", customerRegisterBO.getAccount());
        int loginCount = loginInfoService.selectCount(loginWrapper);
        if (loginCount > 0) {
            return new Result<>(CodeEnum.FAIL_100007.getCode(), "账号已存在");
        }
        
        // 检查手机号是否已存在
        Wrapper<PhoneInfoDTO> phoneWrapper = new EntityWrapper<>();
        phoneWrapper.eq("phone", customerRegisterBO.getPhone());
        int phoneCount = phoneInfoService.selectCount(phoneWrapper);
        if (phoneCount > 0) {
            return new Result<>(CodeEnum.FAIL_100007.getCode(), "手机号已存在");
        }
        
        try {
            // 1. 创建客户信息
            CustomerInfoSaveBO customerInfoSaveBO = new CustomerInfoSaveBO();
            customerInfoSaveBO.setName(customerRegisterBO.getCustomerName());
            customerInfoSaveBO.setType(customerRegisterBO.getCustomerType());
            customerInfoSaveBO.setCommunity(customerRegisterBO.getCommunity());
            
            boolean customerSaved = customerInfoService.add(customerInfoSaveBO);
            if (!customerSaved) {
                return new Result<>(CodeEnum.FAIL_100007.getCode(), "创建客户信息失败");
            }
            
            // 获取刚创建的客户信息
            // 更可靠的方式：通过客户名称和社区查询，并按创建时间倒序排列获取最新的一条记录
            Wrapper<CustomerInfoDTO> customerWrapper = new EntityWrapper<>();
            customerWrapper.eq("name", customerRegisterBO.getCustomerName());
            customerWrapper.eq("community", customerRegisterBO.getCommunity());
            customerWrapper.orderBy("create_time", false); // 按创建时间倒序排列
            customerWrapper.last("LIMIT 1"); // 限制只取一条记录
            CustomerInfoDTO customerInfo = customerInfoService.selectOne(customerWrapper);
            if (customerInfo == null) {
                return new Result<>(CodeEnum.FAIL_100007.getCode(), "获取客户信息失败");
            }
            
            // 2. 创建手机号信息
            // 注意：PhoneInfoServiceImpl.add()方法中会自动创建customer_phone关联关系
            PhoneInfoSaveBO phoneInfoSaveBO = new PhoneInfoSaveBO();
            phoneInfoSaveBO.setPhone(customerRegisterBO.getPhone());
            phoneInfoSaveBO.setStatus(1); // 默认正常状态
            phoneInfoSaveBO.setCustomerId(customerInfo.getCustomerId());
            
            boolean phoneSaved = phoneInfoService.add(phoneInfoSaveBO);
            if (!phoneSaved) {
                return new Result<>(CodeEnum.FAIL_100007.getCode(), "创建手机号信息失败");
            }
            
            // 3. 创建账户信息
            AccountInfoSaveBO accountInfoSaveBO = new AccountInfoSaveBO();
            accountInfoSaveBO.setPhone(customerRegisterBO.getPhone());
            accountInfoSaveBO.setPreDeposit(0L); // 默认预存款为0
            accountInfoSaveBO.setTotalConsumption(0L); // 默认累计消费为0
            accountInfoSaveBO.setMonthConsumption(0L); // 默认当月消费为0
            accountInfoSaveBO.setIsArrears(0); // 默认不欠费
            
            boolean accountSaved = accountInfoService.add(accountInfoSaveBO);
            if (!accountSaved) {
                return new Result<>(CodeEnum.FAIL_100007.getCode(), "创建账户信息失败");
            }
            
            // 获取刚创建的账户信息
            Wrapper<AccountInfoDTO> accountWrapper = new EntityWrapper<>();
            accountWrapper.eq("phone", customerRegisterBO.getPhone());
            AccountInfoDTO accountInfo = accountInfoService.selectOne(accountWrapper);
            if (accountInfo == null) {
                return new Result<>(CodeEnum.FAIL_100007.getCode(), "获取账户信息失败");
            }
            
            // 4. 创建登录信息
            LoginInfoSaveBO loginInfoSaveBO = new LoginInfoSaveBO();
            loginInfoSaveBO.setAccount(customerRegisterBO.getAccount());
            loginInfoSaveBO.setPassword(customerRegisterBO.getPassword()); // 实际项目中应该加密存储
            loginInfoSaveBO.setCusId(customerInfo.getCustomerId());
            
            boolean loginSaved = loginInfoService.add(loginInfoSaveBO);
            if (!loginSaved) {
                return new Result<>(CodeEnum.FAIL_100007.getCode(), "创建登录信息失败");
            }
            
            // 注意：不再手动创建customer_phone关联关系，因为PhoneInfoServiceImpl.add()方法中已经创建了
            
            // 返回成功结果
            Map<String, Object> result = new HashMap<>();
            result.put("customerId", customerInfo.getCustomerId());
            result.put("account", customerRegisterBO.getAccount());
            result.put("phone", customerRegisterBO.getPhone());
            result.put("accountId", accountInfo.getId());
            
            return new Result<>(result);
        } catch (Exception e) {
            log.error("客户注册过程中发生异常", e);
            return new Result<>(CodeEnum.FAIL_100008.getCode(), "注册失败: " + e.getMessage());
        }
    }
    
    /**
     * 验证密码是否正确
     * @param inputPassword 用户输入的密码
     * @param storedPassword 数据库中存储的密码（加密后的）
     * @return 密码是否匹配
     */
    private boolean verifyPassword(String inputPassword, String storedPassword) {
        // 在实际项目中，应该使用安全的密码哈希算法如BCrypt进行密码验证
        // 这里为了兼容现有代码，暂时使用简单的字符串比较
        // 实际应用中应该替换为: return BCrypt.checkpw(inputPassword, storedPassword);
        return inputPassword.equals(storedPassword);
    }
}
// 客户注册信息BO类
class CustomerRegisterBO {
    private String account;       // 登录账号
    private String password;      // 登录密码
    private String customerName;  // 客户名称
    private String customerType;  // 客户类型
    private String community;     // 所属社区
    private String phone;         // 手机号

    // Getters and Setters
    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getCustomerType() {
        return customerType;
    }

    public void setCustomerType(String customerType) {
        this.customerType = customerType;
    }

    public String getCommunity() {
        return community;
    }

    public void setCommunity(String community) {
        this.community = community;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
}